<template>
	<view class="msg-list">

		<view class="msg-item" @tap="changeVisibleType(1)">
			<view class="selected-icon">
				<image v-show="visibleType === 1" class="selected-icon-img" src="../../static/selectedIconBlue.png">
				</image>
			</view>
			<view class="item-left">
				<text class="item-name">公开</text>
				<view class="item-input input-placeholder">所有好友可见</view>
			</view>
		</view>


		<view class="msg-item" @tap="changeVisibleType(2)">
			<view class="selected-icon">
				<image v-show="visibleType === 2" class="selected-icon-img" src="../../static/selectedIconBlue.png">
				</image>
			</view>
			<view class="item-left">
				<text class="item-name">部分可见</text>
				<view class="item-input input-placeholder">选中的好友可见</view>
			</view>
			<view class="item-right">
				<image class="right-arrow-icon" src="../../static/rightTriangleArrow.png"></image>
			</view>
		</view>

		<view class="msg-item" @tap="changeVisibleType(3)">
			<view class="selected-icon">
				<image v-show="visibleType === 3" class="selected-icon-img" src="../../static/selectedIconBlue.png">
				</image>
			</view>
			<view class="item-left">
				<text class="item-name">不给谁看</text>
				<view class="item-input input-placeholder">选中的好友不可见</view>
			</view>
			<view class="item-right">
				<image class="right-arrow-icon" src="../../static/rightTriangleArrow.png"></image>
			</view>
		</view>


		<view class="submit-btn-wrap">
			<largeBtn @btnClk="finish">完成</largeBtn>
		</view>

		<!-- 加好友提示弹窗 -->
		<confirmPop :title="'提示'" :content="confirmPopContent" :btns="confirmPopBtns" @maskClk="closeConfrimPop" @btnClk="confrimPopBtnClk"
			v-show="confirmPopShow">
		</confirmPop>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex"

	export default {
		computed: {
			...mapState(['newEvaluate']),
		},
		data() {
			return {
				confirmPopShow: false,
				confirmPopContent: '添加更多好友，让更多好友看到~',
				visibleType: 1, // 1:所有好友可见 2：选中的朋友可见 3：选中的朋友不可见
				confirmPopBtns:[{
					text: '去添加',
					type: 'confirm'
				}, {
					text: '暂不添加',
					type: 'cancel',
					bgColor:'#E5E5E5'
				}]
			}
		},
		created(){
			this.visibleType = this.newEvaluate.toSeeType
		},
		methods: {
			changeVisibleType(type) {
				this.visibleType = type
				if (type === 1) return
				uni.navigateTo({
					url: `/pages/userDetail/selectVisibleFriends?type=${type}`
				})
			},
			finish() {
				this.$store.commit('updateNewEvaluate', {
					toSeeType: this.visibleType
				})
				// this.confirmPopShow = true
				uni.navigateBack()
			},
			confrimPopBtnClk(item = {}) {
				if (item.type === 'confirm') {
				    uni.navigateTo({
					    url: '/pages/myFriends/index'
				    })
				}
				if (item.type === 'cancel') {
				    uni.navigateBack()
				}
				this.closeConfrimPop()
			},
			closeConfrimPop() {
				this.confirmPopShow = false
			}
		}
	}
</script>

<style>
	page {
		background-color: #F3F7FD;
	}
</style>
<style lang="less">
	.msg-list {
		padding: 30rpx 40rpx;
		padding-bottom: 140rpx;

		.msg-item {
			background: #FFFFFF;
			box-shadow: 0 4rpx 8rpx 0 rgba(218, 227, 248, 0.5);
			border-radius: 10rpx;
			display: flex;
			justify-content: space-between;
			padding: 30rpx;
			padding-left: 100rpx;
			margin-bottom: 40rpx;
			position: relative;

			.selected-icon {
				position: absolute;
				width: 40rpx;
				height: 40rpx;
				left: 30rpx;
				top: 67rpx;
				border-radius: 50%;
				border: 3rpx solid #E5E5E5;

				.selected-icon-img {
					position: absolute;
					width: 48rpx;
					height: 48rpx;
					left: -4rpx;
					top: -4rpx;
				}
			}

			.item-left {
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.item-name {
					font-size: 36rpx;
					font-weight: 500;
					color: #333333;
					line-height: 50rpx;
					margin-bottom: 20rpx;
				}

				.item-input {
					font-size: 30rpx;
					font-weight: 400;
					color: #666;
					line-height: 44rpx;
					width: 500rpx;
				}

				.input-placeholder {
					color: #999;
				}
			}

			.item-right {
				min-height: 110rpx;
				display: flex;
				align-items: center;
				justify-content: center;



				.right-arrow-icon {
					width: 32rpx;
					height: 32rpx;
				}
			}
		}
	}

	.submit-btn-wrap {
		width: 670rpx;
	}
</style>
